package io.renren.modules.jxgk.controller;

import io.renren.common.echarts.EchartsJson;
import io.renren.common.echarts.Legend;
import io.renren.common.echarts.Series;
import io.renren.common.echarts.XAxis;
import io.renren.common.utils.R;
import io.renren.modules.jxgk.entity.TeacherRanking;
import io.renren.modules.jxgk.entity.TempTeacherEvaluation;
import io.renren.modules.jxgk.service.TeacherChartsService;
import io.renren.modules.jxgkphone.entity.CourseDate;
import io.renren.modules.jxgkphone.service.CourseDateService;
import io.renren.modules.jxgkphone.tempEntity.TempTeacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/TeacherCharts")
public class TeacherChartsController {
    @Autowired
    CourseDateService courseDateService;
    @Autowired
    TeacherChartsService teacherChartsService;
    @RequestMapping("/teachingEvaluation")
    public R getTeachingEvaluation(@RequestParam Map<String, Object> params) {
        String option=(String) params.get("option");
        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
        String nowDate=format.format(new Date());
        CourseDate courseDate=courseDateService.getDayInfo(nowDate);
        if(option!=null&&option.equals("term")){
            courseDate.setCourseWhichWeek(null);
        }
        List<TempTeacherEvaluation> list=teacherChartsService.getTeachingEvaluation(courseDate);
        return R.ok().put("list",list);
    }

    @RequestMapping("/getTodayTeacherRanking")
    public R getTodayTeacherRanking()
    {

        List<TeacherRanking> teacherRankingArriveList=teacherChartsService.getTodayArriveTeacherRanking();
        List<TeacherRanking> teacherRankingTimeList=teacherChartsService.getTodayTimeTeacherRanking();

        List<TeacherRanking> teacherRankingLeaveList=teacherChartsService.getTodayLeaveTeacherRanking();
        Integer todayHomework =teacherChartsService.getTodayHomeworkCount();
        return  R.ok().put("teacherRankingArriveList",teacherRankingArriveList)
                        .put("teacherRankingTimeList",teacherRankingTimeList)
                         .put("teacherRankingLeaveList",teacherRankingLeaveList)
                        .put("todayHomework",todayHomework);
    }


}
